import json

from django.http import HttpResponse

from MyModel import models
from MyModel.models import Book
from utils import time_util


def add_book(request):
    pub = models.Publish.objects.filter(pk=1).first()

    date = time_util.time_to_string('%Y-%m-%d')
    book = Book.objects.create(title='Python入门到精通', price=32.25, pub_date=date, publish=pub)

    print(f"add_book={book}")
    return HttpResponse('add success')
